package com.itheima;


import java.util.Random;

/*创建一个长度是100的字符串数组
        使用长度是2的随机字符填充该字符串数组
        统计这个字符串数组里重复的字符串有多少种*/
public class Compare {
    public static void main(String[] args) {
        String[] str = new String[100];
        Random r = new Random();
        for (int i = 0; i < 100; i++) {
            StringBuilder sb = new StringBuilder();
            sb.append((char)(r.nextInt(26)+'A'));
            sb.append((char)(r.nextInt(26)+'A'));
            str[i]= sb.toString();
        }
        for (int i = 0; i < 100; i++) {
            System.out.print(str[i]+" ");
        }
        String strings = new String();
        StringBuilder sbr = new StringBuilder();
        for (int i = 0; i < 100; i++) {
            for (int j = i+1; j < 100; j++) {
                if(str[i].equals(str[j])){
                    sbr.append(str[i]+" ");
                }
            }
        }
        strings = sbr.toString();
        System.out.println("相同的字符为:" +strings);
    }
}
